package cn.hunqing.web.session;

import java.io.Serializable;
import java.util.Date;

import cn.hunqing.web.entity.User;

/**
 * Store the user info in the server session.
 * 
 * @author Kai Zhang
 *
 */
public class SessionUserInfo implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2118932630750147185L;

	private int id;
	private int type;
	private String userName;
	private Date lastLoginTime;
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public Date getLastLoginTime() {
		return lastLoginTime;
	}
	public void setLastLoginTime(Date lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}
	
	public static SessionUserInfo buildFrom(User user) {
		if(user == null){
			return null;
		}
		SessionUserInfo result = new SessionUserInfo();
		result.setId(user.getId());
		result.setUserName(user.getUserName());
		return result;
	}
}
